<div id="content">
                    	<h3>Danh sách sản phẩm</h3>
                        
                        <div id="contentFunc">
                        	<div class="create">
                                <a href="<?php echo base_url() ?>index.php/Quanlysanpham/them">Thêm sản phẩm</a>
                            </div>
                              
                            <div class="search">
								<?php 
									//print_r($sanphams);
                                    $attributes = array('id'=>'frmSP','name'=>'frmSP','method'=>'get');
                                    echo form_open_multipart('Quanlysanpham/index',$attributes);	         
							    ?>
                            	<label>Từ khóa:</label>                          
                                <input type="search" id="txtSearch" name="key"/>
                               
                                  <?php 
								if(isset($danhmucs))
								{
									if(is_array($danhmucs))
									{
											$options = array();
											foreach ($danhmucs as $item)
											{
												$options[$item['madm']]=$item['tendanhmuc'];
											}
										 if(isset($danhmuc))
											{
												echo form_dropdown('dm', $options, $danhmuc); 
											}
										 else
											{
												echo form_dropdown('dm', $options,null);
											}
									}
								}		 
								?>
                                <input type="submit" id="btnSearch" value="Tìm"/>
                                </form>
                            </div>
                             <div class="pageList">
                             	<?php 
									if(isset($pages))
									{
										for ( $p = 1; $p <=$pages+1; $p ++ )
										{
											if(!empty($key)&&!empty($dm))	
											{
											echo "<a href='".base_url()."index.php/Quanlysanpham/index?key={$key}&dm={$dm}&page={$p}'>{$p}</a>";
											}else if(!empty($key))
											echo "<a href='".base_url()."index.php/Quanlysanpham/index?key={$key}&page={$p}'>{$p}</a>";
											
											else if (!empty($dm))
											echo "<a href='".base_url()."index.php/Quanlysanpham/index?dm={$dm}&page={$p}'>{$p}</a>";
											else
											echo "<a href='".base_url()."index.php/Quanlysanpham/index?page={$p}'>{$p}</a>";
										}
									}
								?>
                             </div>
                            <div class="dataSP">
                                <table class="tableSanPham">
                                    <tr class="colName">
                                        <th class="colValue">STT</th>
                                        <th class="colValue">Tên sản phẩm</th>
                                        <th class="colValue">Đơn giá</th>
                                        <th class="colValue">Số lượng</th>
                                        <th class="colValue">Đơn vị tính</th>
                                        <th class="colValue">Số lượt xem</th>
                                        <th class="colValue">Số lượt đặt hàng</th>
                                        <th class="colValue">Xem</th>
                                        <th class="colValue">Sửa</th>
                                        <th class="colValue">Xóa</th>
                                    </tr>
                                  
                                    <?php 
								
										if(!empty($sanphams))
										{
										 
											for($stt=0 ;$stt<count($sanphams);$stt++)
											{	
												
												$sp=$sanphams[$stt];
												echo "<tr class='rowValue'>";
												//echo "<input type='hidden' name='masp[{($stt+1)}]' value='{$sp['masp']}' />";
												echo "<td class='rowId'>".(($page-1) * $pagesize + $stt+1)."</td>";
												echo "<td>{$sp['tensanpham']}</td>";
												echo "<td class='rowId'>{$sp['dongia']}</td>";
												echo "<td class='rowId'>{$sp['soluong']}</td>";
												echo "<td class='rowId'>{$sp['donvitinh']}</td>";
												echo "<td class='rowId'>{$sp['soluotxem']}</td>";
												echo "<td class='rowId'>{$sp['soluotdathang']}</td>";
												echo "<td>";
												echo "<a href='". base_url()."index.php/Quanlysanpham/chitiet/{$sp['masp']}'>";
												echo "<img src='".base_url()."images/sdetail.png' alt='Xem'/>";
												echo "	</a>";
                                                echo "	</td>";
                                                echo "	<td>";
                                                echo "	<a href='".base_url()."index.php/Quanlysanpham/sua/{$sp['masp']}'>";
                                                echo "			<img src='".base_url()."images/sedit.png' alt='Sửa'/>";
                                                echo "	</a>";
                                                echo "	</td>";
                                                echo "	<td>";
												
												if(!empty($key)&&!empty($dm))	
												{
													echo "<a href='".base_url()."index.php/Quanlysanpham/xoa/{$sp['masp']}?key={$key}&dm={$dm}&page={$page}'>";
												}else if(!empty($key))
													echo "<a href='".base_url()."index.php/Quanlysanpham/xoa/{$sp['masp']}?key={$key}&page={$page}'>";
												
												else if (!empty($dm))
													echo "<a href='".base_url()."index.php/Quanlysanpham/xoa/{$sp['masp']}?dm={$dm}&page={$page}'>";
												else
													echo "<a href='".base_url()."index.php/Quanlysanpham/xoa/{$sp['masp']}?page={$page}'>";
													
											    echo "			<img src='".base_url()."images/sdelete.png' alt='Xóa'/>";
                                                echo "		</a>";
                                                echo "	</td>";
                                                echo "</tr>";
													}	
												}
									?>
                                </table>
                            </div>
                        </div>
                    </div>
            </div>
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            